﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace emoneybusiness.shopping
{
    public partial class CardSelect : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                divName.Style.Remove("display");
                divName.Style.Add("display", "block");
                divCard.Style.Add("display", "none");
            }
        }
        protected void btnCheck_Click(object sender, EventArgs e)
        {
            try
            {
                //测试用户名
                if (txtName.Text == "emtest")
                {   
                    divName.Style.Remove("display");
                    divName.Style.Add("display", "none");
                    divCard.Style.Add("display", "block");
                    return;
                }
                if (txtName.Text == "")
                {
                    Response.Write("<script>alert('用户名不能为空!');</script>");
                    return;
                }

                WebService.emoneybusiness eb = new WebService.emoneybusiness();
                int result = eb.CheckUserName_UserLevel(txtName.Text);
                if (result <= 0)
                {
                    Response.Write("<script>alert('用户名不存在!');</script>");
                }
                else if (result == 1)
                {
                    Response.Write("<script>alert('此卡属于主力版用户专用，决策版用户不能购买!');</script>");
                }
                else if (result > 1)
                {
                    divName.Style.Remove("display");
                    divName.Style.Add("display", "none");
                    divCard.Style.Add("display", "block");
                }
            }
            catch(Exception ex)
            {
               // Response.Write("<script>alert('服务器忙，请稍后再试!');</script>");
                Response.Write("<script>alert('"+ex.Message+"');</script>");
            }
        }
    }
}